import { ApiProperty } from '@nestjs/swagger'
import { IsEnum, IsNotEmpty, IsOptional, IsString } from 'class-validator'
import { TUserGender, TUserStatus } from '@/enum/commom.emun'

export class CreateUserDto {
  @ApiProperty({
    name: 'userName',
    description: '用户名',
  })
  @IsString({ message: '用户名不合法' })
  userName: string

  @ApiProperty({
    name: 'userGender',
    description: '性别',
    enum: TUserGender,
    default: TUserGender.male,
  })
  @IsOptional()
  userGender: TUserGender

  @ApiProperty({
    name: 'password',
    description: '密码',
  })
  @IsOptional()
  password: string

  @ApiProperty({
    name: 'nickName',
    description: '昵称',
  })
  @IsOptional()
  nickName: string

  @ApiProperty({
    name: 'userPhone',
    description: '手机号',
  })
  @IsOptional()
  userPhone: string

  @ApiProperty({
    name: 'userEmail',
    description: '邮箱',
  })
  @IsOptional()
  userEmail: string

  @ApiProperty({
    description: '状态',
    enum: TUserStatus,
    default: TUserStatus.enable,
  })
  @IsNotEmpty({ message: '状态不能为空' })
  @IsEnum(TUserStatus, { message: '状态不合法' })
  status: TUserStatus

  @ApiProperty({
    name: 'userRoles',
    description: '角色码',
  })
  @IsOptional()
  userRoles: string[]
}
